package planesimulator.plane.wing.coefficients;

/**
 * Standart drag coefficient
 * @author Jakub Klimek
 */
public class StandartDragCoefficient implements DragCoefficient {

  float keys[] = {
    0.000000f,
    2.000000f,
    4.000000f,
    6.000000f,
    8.000000f,
    10.000000f,
    12.000000f,
    14.000000f,
    16.000000f,
    18.000000f,
    90.000000f,
    180f
  };
  float values[] = {
    0.029874f,
    0.020470f,
    -0.001964f,
    -0.038355f,
    -0.083294f,
    -0.132938f,
    -0.183120f,
    -0.216364f,
    -0.223701f,
    -0.032817f,
    -0.494081f,
    0f
  };
  ValueTable vt;

  public StandartDragCoefficient() {
    vt = new ValueTable(11, keys, values);
  }

  public float drag(float deg) {
    if (deg < 0) {
      return vt.interpolate(-deg);
    } else {
      return vt.interpolate(deg);
    }
  }
}
